import request from "@/utils/request"

// 请求参数类型
export type QuestionParamsType = {
    id:number | null;
    questionType: number | null;
    level: number | null;
    subjectId: number | null;
    pageIndex: number;
    pageSize: number
}

type QuestionResponseType<T> = {
    total: number;
    list: T[]
}

// 返回值类型
export type QuestionType = {
    id: number;
    title: string,
    gradeLevel: number;
    createUserName: string
    createTime: string
    deleted: boolean
    subjectId:number
}

// 删除返回值类型
export type TaskDelete = {
    code: number,  //返回状态
    message: string, //返回消息
    response: string | null  //返回数据
}

// 题目列表接口
export function questionPage(data: QuestionParamsType) {
    return request.post<QuestionResponseType<QuestionType>>("/api/admin/question/page", data)
}


// 删除接口
export function taskDelete(id: number) {
    return request.post<{ code: number; message: string; response: null }>(`/api/admin/question/delete/${id}`)
}

// 学科列表的数据类型
export type SubjectItemType = {
    id:number;
    deleted:boolean;
    itemOrder:null;
    level:number;
    levelName:string;
    name:string;
}
//学科列表
export function subjectList(){
    return request.post<SubjectItemType[]>("/api/admin/education/subject/list")
}